	
function addCityAction() {
	var citySelect = document.getElementById("citySelect");

	var url = "dcmanager/addCityInfo.do";

	var params = {
		cityName : document.getElementById("cityName").value
	};

	//Set empty.
	citySelect.innerHTML = "";

	//Ajax post.
	$.post(url, params, function(data) {
		citySelect.innerHTML = data;
	});

	document.getElementById('addCity').style.display = 'none';
	/*	getCityInfo();*/

}

function getCityInfo() {
	var citySelect = document.getElementById("citySelect");

	var url = "dcmanager/cityInfo.do";

	//Ajax post.
	$.post(url, function(data) {
		citySelect.innerHTML = data;
	});
}

function addBuildingAction() {

	//Get city Id
	var citySelect = document.getElementById("citySelect");
	var fatherId = citySelect[citySelect.selectedIndex].value;

	var buildingSelect = document.getElementById("buildingSelect");

	var url = "dcmanager/addBuildingInfo.do";

	var params = {
		buildingName : document.getElementById("buildingName").value,
		fatherId : fatherId
	};

	//Set empty.
	buildingSelect.innerHTML = "<option>请先选择前置条件</option>";

	//Ajax post.
	$.post(url, params, function(data) {
		buildingSelect.innerHTML = data;
	});

	document.getElementById('addBuilding').style.display = 'none';
	/*	getCityInfo();*/

}



function getBuildingInfo(fId) {
	/*	Get city Id	var citySelect = document.getElementById("citySelect");
	 var fatherId = citySelect[citySelect.selectedIndex].value;*/

	var buildingSelect = document.getElementById("buildingSelect");

	//Clear data
	if (fId == null) {
		buildingSelect.innerHTML = "<option>请先选择前置条件</option>";
		return;
	}

	var url = "dcmanager/buildingInfo.do";

	//Clear Floor Info.
	var floorSelect = document.getElementById("floorSelect");
	floorSelect.innerHTML="<option>请先选择前置条件</option>";

	//Clear Dc Info(If exit).
	var dcSelect = document.getElementById("dcSelect");
	if (dcSelect != null) {
		dcSelect.innerHTML="<option>请先选择前置条件</option>";
	}

	var params = {
		fatherId : fId
	};

	//Ajax post.
	$.post(url, params, function(data) {
		buildingSelect.innerHTML = data;
	});
}

function addFloorAction() {
	//Get floor Id
	var buildingSelect = document.getElementById("buildingSelect");
	var fatherId = buildingSelect[buildingSelect.selectedIndex].value;

	var floorSelect = document.getElementById("floorSelect");

	var url = "dcmanager/addFloorInfo.do";

	var params = {
		floorName : document.getElementById("floorName").value,
		fatherId : fatherId
	};

	//Set empty.
	floorSelect.innerHTML = "<option>请先选择前置条件</option>";

	//Ajax post.
	$.post(url, params, function(data) {
		floorSelect.innerHTML = data;
	});

	document.getElementById('addFloor').style.display = 'none';
	/*	getCityInfo();*/

}

function getFloorInfo(fId) {
	/*	Get floor Id	var buildingSelect = document.getElementById("buildingSelect");
	 var fatherId = buildingSelect[buildingSelect.selectedIndex].value;*/

	var floorSelect = document.getElementById("floorSelect");

	var url = "dcmanager/floorInfo.do";

	var params = {
		fatherId : fId
	};

	//Ajax post.
	$.post(url, params, function(data) {
		floorSelect.innerHTML = data;
	});
}

function createdc() {
	//	Get floor Id	
	var floorSelect = document.getElementById("floorSelect");
	var fatherId = floorSelect[floorSelect.selectedIndex].value;

	var url = "dcmanager/createDC.do";

	var params = {
		fatherId : fatherId,
		desciption : document.getElementById("desciption").value,
		ownerEmail : document.getElementById("manager").value,
		currentUserId : document.getElementById("currentUserId").value
	};

	//Ajax post.
	$.post(url, params, function(data) {
		//refresh.
			alert("Succeed!");
			top.location = "dcmanager/createdc.jsp";
		});
}

function dcManagerAutoCompl() {

	$("#manager").autocomplete("./selectPersonAuto.do", {
		minChars : 0,
		width : 125,
		extraParams : {
			area : function() {
				return $("#manager").val();
			}
		},
		parse : function(data) {
			var obj = eval(data);
			var row = [];
			for ( var i = 0; i < obj.length; i++) {
				row[i] = {
					data : obj[i], //������ʾ��ݸ�ʽ 	
					value : obj[i].realName, //ֵ(�ǳ���Ҫ��ֻ����String)
					result : obj[i].email
				//��ʾ��								
				};
			}
			return row;
		},
		formatItem : function(row, i, max) {
			return row.realName + "\"" + row.empoyeeNum + "\"";
		},
		formatMath : function(row, i, max) {
			return row.realName + " " + row.empoyeeNum;
		},

		formatResult : function(row) {
			return row.email;
		}

	});
}
